Skip to content

Write the fog-node log to a rotating file as well as to the console - #211

Merged
fog-workflows[bot] merged 1 commit into
masterfrom
feat/log-file
Nov 17, 2026
Merged

fog-workflows[bot] merged 1 commit into
masterfrom
feat/log-file

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Closes #208. Map: #155. Prerequisite of #209 (the Log Viewer).

What

  • api/lib/file-logger.js is a captains-log custom logger, wired in config/log.js (inspect: false). It uses Node built-ins only.
  • Each line is 2026-11-17T16:04:42.123Z warn: message. It goes to the console (error, warn and crit to stderr, the rest to stdout) and is appended to <logDir>/fog-node.log.
  • Rotation at 10 MB keeps .1 to .5. A failed rename (Windows, a reader without share-delete) writes one stderr notice, keeps appending, and retries after another tenth of the limit. A log call never throws.
  • logDir is custom.logDir in config/local.js, else <app>/logs. The installer keeps an existing custom.logDir on a re-run, as it keeps custom.pkiDir (readOldLocal, customLines). It asks no new question.
  • docs/install.md gains a section on the log file.

Behavior change

  • The console prefix changes from captains-log's warn: to the time and the level.
  • At the production level debug, the info, verbose and silly lines are not written. That is captains-log's level order, unchanged. The docs say so.

Tests

  • npm test: 549 passing. npm run test:ui, npm run test:ui:prod and npm run test:install pass. No logs/ folder is left in the checkout.
  • New tests: test/lib/file-logger.test.js (format, console split, rotation, the five-file limit, an unwritable folder, the rename-failure retry), test/lib/log-file-lift.test.js, and test/setup/read-old-local.test.js. Each fails without the change.
  • The mocha, UI-smoke and installer lifts log to temporary folders.

Review

Built by an executor (Sonnet). Spec review on Opus and standards review on Sonnet, two rounds each. The last finding was applied.

🤖 Generated with Claude Code

…onsole

fog-node logged to stdout and stderr only, so its log lived in journald,
NSSM or launchd, which Node cannot read on every OS. The FOG 1.6 Log
Viewer (#209) needs a file.

- api/lib/file-logger.js: a captains-log custom logger (Node built-ins
  only). Each line is "<ISO time> <level>: <message>", on the console
  (error/warn/crit to stderr) and appended to <logDir>/fog-node.log.
- Rotation at 10 MB, five old files kept. A failed rename (Windows,
  another program holding the file) logs once, keeps appending, and
  retries after another tenth of the limit. A log call never throws.
- logDir: custom.logDir in config/local.js, else <app>/logs. The
  installer keeps an existing custom.logDir on a re-run, as it keeps
  custom.pkiDir.
- Behavior change: the console prefix changes from captains-log's
  "warn: " to the time and level. At the production level "debug",
  info, verbose and silly lines are not written (captains-log order).
- The mocha, UI-smoke and installer lifts log to temporary folders.

Closes #208

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 17, 2026 17:49
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 529ccf8 Nov 17, 2026
6 checks passed
@fog-workflows
fog-workflows Bot deleted the feat/log-file branch November 17, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write the fog-node log to a rotating file as well as to the console

1 participant